home *** CD-ROM | disk | FTP | other *** search
- Path: news.ccs.queensu.ca!news
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
- Subject: Re: C++ with Zapp vs. Delphi
- Date: Thu, 18 Jan 1996 15:33:13 GMT
- Organization: Queen's University, Kingston
- Message-ID: <30fe666e.3349285@130.15.126.54>
- References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu> <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu>
- NNTP-Posting-Host: djm.mast.queensu.ca
- X-Newsreader: Forte Agent .99c/16.141
-
- On 18 Jan 1996 07:27:29 GMT, olczyk@sunphy1 (Jung Oh) wrote:
-
- >But it does raise an interesting problem.
- >How do you write a class SortedList which maintains a list of objects which
- >have a method CompareTo. This lists keeps the objects in sorted order based
- >on CompareTo.
- ...
- >If you have MI it's easy. Just create a class called SortedObject with
- >a virtual method called CompareTo. Store objects of that type in the list.
-
- The way this is done in Delphi is to create a descendant of the
- SortedList that overrides the compare method. Instead of forcing you
- to only put SortedObjects in the list, this allows you to put anything
- there, even non-objects like integers or strings or empty holes, if
- that suits your fancy.
-
- There's not a big difference, but I think this is a little bit
- preferable. It makes it clear that it's up to the list to know about
- sorting, not up to the object. That way you can easily put the same
- object in multiple lists with different sorting rules.
-
- Duncan Murdoch
-
- P.S. Your newsreader isn't configured properly; it's not giving a
- valid return address (see above).
-